package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Reservation;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReservationMapper {
    @Select("select phone from member where id = #{mgtUserId}")
    String selectNumber(@Param("mgtUserId")Long mgtUserId);

    Integer getCancelledCount(Reservation reservation);

    void insert(Reservation reservation);
    List<Reservation> findByPage(Integer status, Long userId);

    @Select("select * from reservation where id = #{id}")
    Reservation findById(Long id);

    void updateCancel(Reservation reservation);

    @MapKey("time")
    List<Map<String, Object>> countByTime(LocalDateTime startTime, LocalDateTime endTime);

    @Select("select * from reservation where status = 0 and time < #{now}")
    List<Reservation> getReservationsByTime(LocalDateTime now);

    @Update("update reservation set status = #{status} where id = #{id}")
    void GQ(Reservation reservation);
}
